package database;

import Other.Glob;
import enums.SearchType;

public class MyTransport extends NewTirDataBase {

	private String transportID;
	private String lorry;
	private String departure;
	private String agent;
	private String destinationCode;
	private String destinationName;
	private String supplierCode;
	private String supplierName;
	private String countryCode;
	private String countryName;
	private String comments;

	
	private static final int TRANSPORT_ID = 0;
	private static final int LORRY = 1;
	private static final int DEPARTURE = 2;
	private static final int AGENT = 3;
	private static final int DESTINATION_CODE = 4;
	private static final int SUPPLIER_CODE = 5; 
	private static final int COUNTRY_CODE = 6;
	private static final int COMMENTS = 7;

	public MyTransport() {
		
		
	}
	
	public MyTransport(String [] data) {

		super();
		this.transportID = data[TRANSPORT_ID];
		this.lorry = data[LORRY];
		this.departure = data[DEPARTURE];
		this.agent = data[AGENT];
		this.destinationCode = data[DESTINATION_CODE];
		this.supplierCode = data[SUPPLIER_CODE];
		this.countryCode = data[COUNTRY_CODE];
		this.comments = data[COMMENTS];
		
		
destinationName ="";
		
		Glob.setType(SearchType.DESTINATION);
		for (NewTirDataBase d : DatabaseExtension.getTableID("Select * from destination")) {
			if (((MyDestination) d).getDestinationID().trim().replaceAll("\n", "").equals(destinationCode)) {
				destinationName = String.format("%s",((MyDestination) d).getName());
			
	}
		}
	
supplierName ="";
		
		Glob.setType(SearchType.SUPPLIER);
		for (NewTirDataBase s : DatabaseExtension.getTableID("Select * from supplier")) {
			if (((MySupplier) s).getSupplierID().trim().replaceAll("\n", "").equals(supplierCode)) {
				supplierName = String.format("%s",((MySupplier) s).getName());
			
	}
		}
		
countryName ="";
		
		Glob.setType(SearchType.COUNTRY);
		for (NewTirDataBase c : DatabaseExtension.getTableID("Select * from country")) {
			if (((MyCountry) c).getCountryID().trim().replaceAll("\n", "").equals(countryCode)) {
				countryName = String.format("%s",((MyCountry) c).getCountryName());
			
	}
		}
		
		
		Glob.setType(SearchType.TRANSPORT);
			
		}

	public String getTransportID() {
		return transportID;
	}

	public void setTransportID(String transportID) {
		this.transportID = transportID;
	}

	public String getLorry() {
		return lorry;
	}

	public void setLorry(String lorry) {
		this.lorry = lorry;
	}

	public String getDeparture() {
		return departure;
	}

	public void setDeparture(String departure) {
		this.departure = departure;
	}

	public String getAgent() {
		return agent;
	}

	public void setAgent(String agent) {
		this.agent = agent;
	}

	public String getDestinationCode() {
		return destinationCode;
	}

	public void setDestinationCode(String destinationCode) {
		this.destinationCode = destinationCode;
	}

	public String getDestinationName() {
		return destinationName;
	}

	public void setDestinationName(String destinationName) {
		this.destinationName = destinationName;
	}

	public String getSupplierCode() {
		return supplierCode;
	}

	public void setSupplierCode(String supplierCode) {
		this.supplierCode = supplierCode;
	}

	public String getSupplierName() {
		return supplierName;
	}

	public void setSupplierName(String supplierName) {
		this.supplierName = supplierName;
	}

	public String getCountryCode() {
		return countryCode;
	}

	public void setCountryCode(String countryCode) {
		this.countryCode = countryCode;
	}

	public String getCountryName() {
		return countryName;
	}

	public void setCountryName(String countryName) {
		this.countryName = countryName;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}	
	
	
	
	
}
